//
//  LLLineUtilies.m
//  JunKeDai
//
//  Created by DD on 2017/12/29.
//  Copyright © 2017年 DD. All rights reserved.
//

#import "LLLineUtilies.h"

@implementation LLLineUtilies

+ (void)addLineInView:(UIView *)superView startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint lineColor:(UIColor *)lineColor
{
    return [self addLineInView:superView startPoint:startPoint endPoint:endPoint lineColor:lineColor lineWidth:1];
}


+ (void)addLineInView:(UIView *)superView startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint lineColor:(UIColor *)lineColor lineWidth:(CGFloat)lineWidth
{
    UIBezierPath *bezierPath = [UIBezierPath bezierPath];
    [bezierPath moveToPoint:startPoint];
    [bezierPath addLineToPoint:endPoint];
    CAShapeLayer *shapelayer = [CAShapeLayer layer];
    shapelayer.strokeColor = lineColor.CGColor;
    shapelayer.lineWidth = lineWidth;
//    shapelayer.lineCap = kCALineCapRound;
    shapelayer.path = bezierPath.CGPath;
    [superView.layer addSublayer:shapelayer];
}

+ (void)addDashLineInView:(UIView *)superView startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint lineColor:(UIColor *)lineColor lineWidth:(CGFloat)lineWidth
{
    UIBezierPath *bezierPath = [UIBezierPath bezierPath];
    [bezierPath moveToPoint:startPoint];
    [bezierPath addLineToPoint:endPoint];
    
    CAShapeLayer *shapelayer = [CAShapeLayer layer];
    shapelayer.strokeColor = lineColor.CGColor;
    shapelayer.lineWidth = lineWidth;
    //    shapelayer.lineCap = kCALineCapRound;
    shapelayer.path = bezierPath.CGPath;
    [shapelayer setLineDashPattern:@[@4, @2]];
    [superView.layer addSublayer:shapelayer];
}

@end
